<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>用arguments获取传递的实参</title>
	</head>
	<body>
		<div id="div1" style="width: 200px;background: red;height: 200px;"></div>
		<script>
			//页面加载时执行
			window.onload=function(){
				var div1=document.getElementById('div1');
				//获取div1元素的width属性值
				alert(css(div1,'width'));
				//设置div1元素的background属性为green
				css(div1,'background','green');
			};
			//传入2个参数，获取属性值；传入3个参数，设置属性值
			function css(){
				if(arguments.length==2){
					return arguments[0].style[arguments[1]];
				}else if(arguments.length==3){
				    //div1.style.backgroud=green;
				    arguments[0].style[arguments[1]]=arguments[2];
				    //div1.style.backgroud=green;
				    //arguments[0].style[arguments[1]]=arguments[2];
				}else{
					alert("no");
				}
			}
		</script>
	</body>
</html>
